<?php

namespace ms\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use ms\models\SysRecharge;

/**
 * SysRechargeSearch represents the model behind the search form about `ms\models\SysRecharge`.
 */
class SysRechargeSearch extends SysRecharge
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'uid', 'cardid', 'status', 'operatorid', 'type', 'apply_time', 'audit_time', 'orderid','dksj'], 'integer'],
            [['account'], 'number'],
            [['remark'], 'safe'],
            [['uid'], 'string', 'max' => 120]
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = SysRecharge::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'uid' => $this->uid,
            'account' => $this->account,
            'cardid' => $this->cardid,
            'status' => $this->status,
            'operatorid' => $this->operatorid,
            'type' => $this->type,
            'apply_time' => $this->apply_time,
            'audit_time' => $this->audit_time,
            'orderid' => $this->orderid,
        ]);

        $query->andFilterWhere(['like', 'remark', $this->remark]);

        return $dataProvider;
    }
}
